这是我们昨天的 Pipeline 项目的示例,今天我们就通过它来讲解一下 Jenkinsfile 语法。
pipeline {
    agent any 
    stages {
        stage('Stage 1') {
            steps {
                sh 'echo Hello world!' 
            }
        }
        stage('Stage 2') {
            steps {
                sh 'echo I am Aaron.' 
            }
        }
    }
}
Jenkinsfile 通过 “{}” 来实现分层,将整个文件拆分成多个语句块。
pipeline:包含了 pipeline 需要执行的所有指令(块)。
更多语法细节:
https://www.jenkins.io/doc/book/pipeline/syntax/